package com.aaa.controller;


import com.aaa.entity.CommentPraise;
import com.aaa.mapper.CommentPraiseMapper;
import com.aaa.service.impl.CommentPraiseServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Bean
 * @since 2021-09-07
 */
@Api(tags = "评论赞")
@RestController
@CrossOrigin
@RequestMapping("/comment-praise")
public class CommentPraiseController {

    @Autowired
    CommentPraiseServiceImpl commentPraiseService;

    @ApiOperation("评论点赞")
    @RequestMapping(value = "add",method = RequestMethod.POST)
    public boolean add(@ApiParam("cid") Integer cid,@ApiParam("uid") Integer uid){
        boolean add = commentPraiseService.add(cid, uid);
        return add;
    }

    @ApiOperation("取消评论赞")
    @RequestMapping(value = "deleatten",method = RequestMethod.POST)
    public boolean deleatten(@ApiParam("cid") Integer cid,@ApiParam("uid")Integer uid){
        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("cid",cid);
        objectObjectHashMap.put("uid",uid);
        return commentPraiseService.removeByMap(objectObjectHashMap);
    }
}
